/*
 * @Author: wangchao
 * @Date: 2024-10-04 15:07:32
 * @LastEditors: wangchao
 * @LastEditTime: 2024-10-09 13:48:02
 * @FilePath: \JD-RTT-Driver\applications\u_app_stop.h
 * @Description:
 * Copyright (c) 2024 by Bingshan Guardian, All Rights Reserved.
 */
#ifndef _U_APP_STOP_H_
#define _U_APP_STOP_H_

#include <rtthread.h>
#include <rtdevice.h>
#include "board.h"

/**
 *  APP停机模式定义
 */
typedef enum
{
    STOP_DO_LONG_TIME,
    STOP_DO_STANDARD,
    STOP_DO_EMERGENCY,
    STOP_DO_INTERRUPT,
} VAR_APP_STOP_MODE;

/**
 * 用户主动停机处理步骤
 */
typedef enum
{
    USER_SHUTDOWN_STEP_PCS_STOP,                 // PCS停机
    USER_SHUTDOWN_STEP_STOP_FLOW_CONTROL,        // 停止流量控制
    USER_SHUTDOWN_STEP_STOP_PUMP,                // 停止泵
    USER_SHUTDOWN_STEP_WAIT_PUMP_STOP,           // 等待泵停止
    USER_SHUTDOWN_STEP_DELAY_WAIT_1,             // 等待延时1
    USER_SHUTDOWN_STEP_CLOSE_OUTLET_VALVE,       // 关闭出口阀
    USER_SHUTDOWN_STEP_WAIT_OUTLET_VALVE_CLOSE,  // 等待出口阀关闭
    USER_SHUTDOWN_STEP_DELAY_WAIT_2,             // 等待延时2
    USER_SHUTDOWN_STEP_HMI_FEEDBACK              // HMI反馈
} USER_SHUTDOWN_STEP;

typedef enum
{
    EMG_SHUTDOWN_STEP_STOP_PUMP,          // 停止泵
    EMG_SHUTDOWN_STEP_PCS_STOP,           // PCS停机
    EMG_SHUTDOWN_STEP_ALERT_EMS,          // 告警EMS
    EMG_SHUTDOWN_STEP_PCS_INTERLOCK_OFF,  // PCS联锁断开
    EMG_SHUTDOWN_STEP_HMI_FEEDBACK        // HMI反馈
} EMG_SHUTDOWN_STEP;

VAR_APP_STOP_MODE get_current_app_stop_mode(void);
void set_current_app_stop_mode(VAR_APP_STOP_MODE mode);
void app_do_stop_runner(void);

#endif
